// Copyright © 2023 OpenIM. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package organization

import (
	"errors"
)

// CreateOrganizationReq check
func (x *CreateOrganizationReq) Check() error {
	if x.OrganizationInfo == nil {
		return errors.New("OrganizationInfo is empty ")
	}
	return nil
}

// UpdateOrganizationReq check
func (x *UpdateOrganizationReq) Check() error {
	if x.OrganizationInfo == nil {
		return errors.New("OrganizationInfo is empty ")
	}
	return nil
}

// DeleteOrganizationReq check
func (x *DeleteOrganizationReq) Check() error {
	if x.OrganizationID == "" {
		return errors.New("OrganizationID is empty ")
	}
	return nil
}

// GetOrganizationsReq check
func (x *GetOrganizationsReq) Check() error {
	if x.ParentID == "" {
		return errors.New("parentID is nil")
	}
	if x.Path == "" {
		return errors.New("path is invalid")
	}

	return nil
}

// GetOrganizationReq check
func (x *GetOrganizationReq) Check() error {
	if x.OrganizationID == "" {
		return errors.New("OrganizationID is invalid")
	}
	return nil
}

// CreateEmployeeReq check
func (x *CreateEmployeeReq) Check() error {
	if x.EmployeeInfo == nil {
		return errors.New("EmployeeInfo is empty")
	}

	return nil
}

// UpdateEmployeeReq check
func (x *UpdateEmployeeReq) Check() error {
	if x.EmployeeInfo == nil {
		return errors.New("EmployeeInfo is empty")
	}
	return nil
}

// DeleteEmployeeReq check
func (x *DeleteEmployeeReq) Check() error {
	if x.EmployeeID == "" {
		return errors.New("employeeId is empty")
	}
	return nil
}

// GetEmployeesReq check
func (x *GetEmployeesReq) Check() error {
	if x.OrganizationID <= 0 {
		return errors.New("organizationId is invalid")
	}
	//if x.Pagination == nil {
	//	return errors.New("pagination is nil")
	//}
	//if x.Pagination.PageNumber < 1 {
	//	return errors.New("pageNumber is invalid")
	//}
	//if x.Pagination.ShowNumber < 1 {
	//	return errors.New("showNumber is invalid")
	//}
	return nil
}

// GetEmployeeReq check
func (x *GetEmployeeReq) Check() error {
	if x.EmployeeId == "" {
		return errors.New("employeeId is empty")
	}
	return nil
}

func (x *GetRootOrganizationsReq) Check() error {
	return nil
}

func (x *GetMyOrganizationsReq) Check() error {
	if x.EmployeeID == "" {
		return errors.New("EmployeeID is empty")
	}
	return nil
}

func (x *GetOrganizationWithChildrenReq) Check() error {
	if x.OrganizationID == "" {
		return errors.New("OrganizationID is empty")
	}
	return nil
}
